var year = [];
var totalOfPrice = [];
var totalOfConsume = [];
var foodOfPrice = [];
var foodOfConsume = [];
var clothesOfPrice = [];
var clothesOfConsume = [];
var city;
var url = location.search; //获取url中"?"符后的字串
if (url.indexOf("?") != -1) {
    city = decodeURI(url.substr(1).split("=")[1]);
}

$.ajax({
    type: "post",
    async: false,            //异步请求（同步请求将会锁住浏览器，用户其他操作必须等待请求完成才可以执行）
    url: "ZhejiangPriceIndexServlet?city=" + city,    //请求发送到TestServlet处
    data: {},
    dataType: "json",
    //返回数据形式为json
    success: function (json) {

        //请求成功时执行该函数内容，result即为服务器返回的json对象
        if (json) {

            for (var key in json[0]) {

                if (key == "总体消费指数") {
                    totalOfConsume = json[0][key].substring(0, json[0][key].lastIndexOf(',')).split(',');
                }

                if (key == "食品消费") {
                    foodOfConsume = json[0][key].substring(0, json[0][key].lastIndexOf(',')).split(',');
                }
                if (key == "衣着消费") {
                    clothesOfConsume = json[0][key].substring(0, json[0][key].lastIndexOf(',')).split(',');
                }
                if (key == "总体价格指数") {
                    totalOfPrice = json[0][key].substring(0, json[0][key].lastIndexOf(',')).split(',');
                }
                if (key == "食品价格") {
                    foodOfPrice = json[0][key].substring(0, json[0][key].lastIndexOf(',')).split(',');
                }
                if (key == "衣着价格") {
                    clothesOfPrice = json[0][key].substring(0, json[0][key].lastIndexOf(',')).split(',');
                }
                if (key == "年份") {
                    year = json[0][key].substring(0, json[0][key].lastIndexOf(',')).split(',');
                }

            }
        }
    }
});